home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-05-21 | 2.8 KB | 95 lines |
- /* $Id: AboutPopup.java,v 1.2 1996/03/31 11:43:02 djun Exp djun $
-
- File: AboutPopup.java
-
- Author: Djun M. Kim
- Copyright (c) 1996 Djun M. Kim. All rights reserved.
-
- This pops up a frame with an "About this applet" message.
- */
-
- import java.awt.*;
-
- public class AboutPopup extends Frame {
-
- MapInfo parent;
- private DisplayArea message_area;
-
- // Constructor
- AboutPopup(MapInfo target) {
- super("About this applet:");
- this.parent = target; // get our parent
- setBackground(Color.lightGray);
- message_area = new DisplayArea("display_area", this, parent);
- resize(360, 240);
- Point p = parent.location();
- move(p.x + 300, p.y + 100);
- setLayout(new GridLayout(1,1));
- add(message_area);
- }
- }
-
-
- class DisplayArea extends gridPanel {
-
- final int REMN = GridBagConstraints.REMAINDER;
- Button close;
-
- DisplayArea(String label, Container target, MapInfo parent) {
- super(label, target);
- CenteredText display = new CenteredText();
- // Name gridx gridy WeightX WeightY gridW gridH
- make_panel( display, 1, 1, 1.0, 1.0, REMN, 1);
- close =
- make_button("OK", 1, 2, 1.0, 0.0, REMN, REMN);
- }
-
- public boolean action(Event evt, Object arg) {
- if (evt.target instanceof Button) {
- Button b = (Button)evt.target;
- if (b == close) {
- if (getParent().isShowing())
- getParent().hide();
- }
- }
- return true;
- }
- }
-
-
- class CenteredText extends Panel {
-
- private Font bold = new Font("TimesRoman", Font.BOLD, 18);
- private Font med = new Font("TimesRoman", Font.PLAIN, 18);
- private Font small = new Font("TimesRoman", Font.PLAIN, 14);
- private FontMetrics bold_fm = getFontMetrics(bold);
- private FontMetrics med_fm = getFontMetrics(med);
- private FontMetrics small_fm = getFontMetrics(small);
- private String name_string = "MapInfo demo 1.0";
- private String author_string = "Copyright (c) 1996 Djun M. Kim";
- private String credits_string = "Map courtesy of UBC Campus Planning & Development";
- private String info_1 = "Send e-mail to djun@math.ubc.ca for more";
- private String info_2 = "information about this project.";
-
-
- public void drawCentered(String s, Container target, Graphics g, Font f, int voffset) {
- FontMetrics fm = getFontMetrics(f);
- g.setFont(f);
- int xstart = (target.size().width - fm.stringWidth(s)) / 2;
- int ystart = (target.size().height - fm.getHeight()) / 6;
- g.drawString(s, xstart, ystart + voffset);
- }
-
- public void paint(Graphics g) {
- setBackground(Color.white);
- setForeground(Color.lightGray);
- drawCentered(name_string, this, g, bold, 10);
- drawCentered(author_string, this, g, med, 30 );
- drawCentered(credits_string, this, g, small, 50);
- drawCentered(info_1, this, g, small, 65);
- drawCentered(info_2, this, g, small, 80);
- }
- }
-
-
-